package com.xhui.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xhui.entity.Book;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;

@SpringBootTest
public class IBookServiceTestCase {

    @Resource
    private IBookService bookService;

    @Test
    void testSave(){
        Book book = new Book();
        book.setType("测试数据类型");
        book.setName("测试数据名称123");
        book.setDescription("测试数据描述");
        bookService.save(book);
    }

    @Test
    void testDelete(){
        bookService.removeById(10);
    }

    @Test
    void testUpdate(){
        Book book = new Book();
        book.setId(11);
        book.setName("testdata1");
        book.setType("testdata1");
        book.setDescription("testdata1");
        System.out.println("result: " + bookService.updateById(book) );
    }

    @Test
    void testGetAll(){
        bookService.list();
    }

    @Test
    void testGetPage(){
        Page<Book> bookPage = new Page<>(2, 5);
        System.out.println(bookService.page(bookPage).getRecords());
    }

    @Test
    void testGetById(){
        System.out.println( bookService.getById(4) );
    }


}
